package utils;

public class DirectoryResolver {
	private static String absoluteBaseDirectoryPath = null;
	
	public static String getAbsoluteBaseDirectoryPath() {
		if(absoluteBaseDirectoryPath == null)
			absoluteBaseDirectoryPath = determineAbsoluteBaseDirectoryPath();
		
		return absoluteBaseDirectoryPath;
	}
	
	private static String determineAbsoluteBaseDirectoryPath() {
		String retval = null;
		
		String temp = DirectoryResolver.class.getClassLoader().getResource("").getPath();
		
		if(temp != null && temp != "")
			retval = temp.substring(1, temp.indexOf("WEB-INF"));
		
		if(retval != null && retval != "")
			retval = retval.replaceAll("%20", " ");
		
		return retval;
	}
}
